<?php
/**
 * SignDefault.php
 * Created by PhpStorm.
 * User: 江小波
 * Date: 2019/5/10
 * Time: 10:03
 */
namespace app\api\sign;

class SignDefault extends SignAbstract
{
    protected $oldSign;
    protected $newSign;
    public function __construct($param=[])
    {
        $this->oldSign = $param['sign'];
        unset($param['sign']);

        ksort($param);

        // 签名
        $tSign='';
        foreach ($param as $key => $val) {
            $tSign.=$key;
            $tSign.='=';
            $tSign.=$val;
        }

        $appSecret = $this->getAppSecretByKey($param['app_key']);
        $this->newSign = strtoupper(md5( $appSecret.$tSign.$appSecret ));
    }
    public function get()
    {
        return $this->newSign;
    }
    public function check()
    {
        return $this->newSign===$this->oldSign;
    }
}